-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implemented date
#38
base: main
Are you sure you want to change the base?
Implemented date
#38
Conversation
hello thanks for your contribution! please also add |
@proh14 I now added |
@@ -1,6 +1,338 @@ | |||
#define _POSIX_C_SOURCE 200112L // for setenv |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You will need to create your own setenv
. Fear not, it is simpler than it seems.
Take a look at glibc implementaion or muscl one
} | ||
} | ||
|
||
#define s(i) (str[i] - '0') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For readability purposes, you may want to avoid doing define within functions
static void use_iso_fmt(char *iso) { | ||
if (!strcmp(iso, "hours")) { | ||
set_operand("+%FT%H%:z"); | ||
} else if (!strcmp(iso, "minutes")) { | ||
set_operand("+%FT%H:%M%:z"); | ||
} else if (!strcmp(iso, "date")) { | ||
set_operand("+%F"); | ||
} else if (!strcmp(iso, "seconds")) { | ||
set_operand("+%FT%T%:z"); | ||
} else if (!strcmp(iso, "ns")) { | ||
set_operand("+%FT%T,%N%:z"); | ||
} else { | ||
fprintf(stderr, "date: invalid argument '%s' for '--iso-8601'\n", iso); | ||
fprintf(stderr, | ||
"must be one of 'hours', 'minutes', 'date', 'seconds', 'ns'\n"); | ||
exit(EXIT_FAILURE); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rebase and move to getopt_long
static bool strpre(const char *pre, const char *str) { | ||
return !strncmp(pre, str, strlen(pre)); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider
static bool strpre(const char *pre, const char *str) { | |
return !strncmp(pre, str, strlen(pre)); | |
} | |
#define strpre(pre, str) (!strncmp((pre), (str), sizeof (pre) - 1)) |
I implemented
date
(issue #6) as described by the POSIX standard.I did implement support for changing the system time.
I did not implement any features that are not described in the POSIX standard.